/*
 * RtpSocket.h
 *
 *  Created on: 2018年5月1日
 *      Author: chuanjiang.zh@qq.com
 */

#ifndef RTPSOCKET_H_
#define RTPSOCKET_H_

#include "RtpPacker.h"
#include "NetAddress.h"
#include <functional>

namespace av
{

class RtpSocket;


typedef std::function<void (RtpPacket&)> 		RtpPacketHandler;

typedef std::function<void (RtpSocket*, int)> 	ConnectionHandler;


class RtpSocket
{
public:
	enum State
	{
		kDisconnected = 0,
		kConnecting,
		kConnected,

	};

	static int SEND_BUFFER_SIZE;
	static int RECV_BUFFER_SIZE;

	static const int MIN_BUFFER_SIZE = 1024 * 256;

public:
	virtual ~RtpSocket() {}

	virtual bool open(const char* ip, int port) =0;
	virtual void close() =0;
	virtual bool isOpen() =0;

	virtual NetAddress getLocalAddr() =0;

	virtual bool setPeer(const char* ip, int port) =0;

	virtual bool send(RtpPacket& packet, int ms) =0;

	virtual bool recv(RtpPacketHandler handler, int ms) =0;

	virtual void setConnectionHandler(ConnectionHandler handler) =0;

	virtual void setTimeout(int ms) =0;

	virtual bool isConnected() =0;

	virtual void setSsrc(uint32_t ssrc) =0;

	virtual void abort() =0;

};


} /* namespace av */

#endif /* RTPSOCKET_H_ */
